package com.ys.fmms.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ys.fmms.pojo.DataSync;
import com.ys.fmms.pojo.DateTimeVo;
import com.ys.fmms.service.DataSyncService;
import com.ys.fmms.util.Result;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@Api(tags = "数据同步")
@RequestMapping("/fmms/dataSyncController")
public class DataSyncController {
    @Autowired
    private DataSyncService dataSyncService;

    @Operation(summary = "获取数据同步历史记录")
    @RequestMapping("/getDataSyncInfo/{pageNo}/{pageSize}")
    @ResponseBody
    public Result getDataSyncInfo(@PathVariable(value = "pageNo") Integer pageNo,
                                  @PathVariable Integer pageSize,
                                  @RequestParam(value = "type",required = false) String type,
                                  @RequestParam(required = false) String userName,
                                  @RequestParam(required = false) String startDate,
                                  @RequestParam(required = false) String endDate){
        Page<DataSync> page = new Page(pageNo,pageSize);
        DateTimeVo date = new DateTimeVo(startDate,endDate);
        IPage<DataSync> iPage = dataSyncService.getDataSyncInfo(page,type,userName,date);
        return Result.ok(iPage);
    }
}
